package org.hamster.test.common.flexUnitTests
{
	import flexunit.framework.Assert;
	
	import mx.utils.XMLUtil;
	
	import org.hamster.common.services.ConfigService;
	import org.hamster.common.services.model.ConfigVO;
	import org.hamster.common.utils.CommonUtil;
	import org.hamster.test.common.flexUnitTests.model.TestConfigVO;
	
	public class ConfigServiceTestCase
	{
		private var sampleConfigXML1:XML = 
			<configList>
				<config>
					<p1>v1</p1>
					<p2>v2</p2>
					<p3>123.345</p3>
					<a1>av1</a1>
					<a1>av2</a1>
					<a1>av3</a1>
				</config>
			</configList>;
		
		private var configService:ConfigService = ConfigService.instance;
		
		[Before]
		public function setUp():void
		{
		}
		
		[After]
		public function tearDown():void
		{
		}
		
		[BeforeClass]
		public static function setUpBeforeClass():void
		{
		}
		
		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}
		
		
		[Test]
		public function test01Init():void
		{
			configService.init(sampleConfigXML1, TestConfigVO);
			var configVO:ConfigVO = configService.configVO;
			Assert.assertEquals(configVO.p1, "v1");
			Assert.assertEquals(configVO.p2, "v2");
			Assert.assertEquals(configVO.p3, 123.345);
			Assert.assertEquals(configVO.a1.toString(), ['av1','av2','av3'].toString());
			
			var resultXML:XML = configService.toXML();
			Assert.assertTrue(CommonUtil.xmlEquals(resultXML, sampleConfigXML1));
		}
		
	}
}